One of the more common operations in computer software is the access of an element of a data structure. This access is usually given as the base address of the data structure with an index to the element within the structure. This is especially common in the accessing of elements within an array. The computer software program generally indicates the ith element of an array using nomenclature such as “x=array[i].” When the array is a half word, word; or double word, the index is oftentimes converted to a byte offset by shifting the index value left by 1, 2, or 3 bit positions to get the offset, which is then added to the base address. This generates the final address, which is used to access data in memory.
The common approach to implement the conversion from index to offset is to utilize a general purpose shifter with an adder in the execute stage of the pipeline. A general purpose shifter has the capability to shift left, shift logical right, shift arithmetic right, and rotate right, all by 0 to 32 bit positions. The general purpose shifter shifts the index the appropriate amount, which consumes the first clock cycle. An adder then adds this value with the base address, consuming the second clock cycle.
The disadvantage of this configuration is the consumption of two clock cycles to perform this frequent operation. Because the processor performs this operation numerous times during operation, processor time is lost due in part to this time consuming operation.
Accordingly, there is a heretofore unaddressed need to overcome the definitions and shortcomings described above.